<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j">           


<ui:composition template="/resources/jsf/component/include/default.xhtml">
    
    <ui:define name="head">        
        <ui:include src="/resources/jsf/component/composition/system/css/default.xhtml" />
    </ui:define>
    
    <ui:define name="left-content" >
        <ui:include src="/resources/jsf/component/composition/user/product/picture/product-picture.xhtml" />
    </ui:define>

    <ui:define name="content">
        <h2>Novo produto</h2>
        <h:link value="adicionar foto" outcome="/user/product/picture/picture" />
        
        <h:form id="form_add_product">
            <h:panelGrid columns="3">
                <h:outputLabel for="status" value="Produto:" />
                <h:selectOneMenu id="status" value="#{productc.productb.product.status}" converter="#{statusConverter}" validator="statusValidator">
                    <f:selectItems value="#{utila.status}" var="status" itemValue="#{status.id}" itemLabel="#{status.status}" />
                    <f:ajax event="blur" render="m_status" />
                </h:selectOneMenu>
                <rich:message id="m_status" for="status" />
                
                <h:outputLabel for="operation" value="Operação:" />
                <h:selectOneMenu id="operation" value="#{productc.productb.product.operation}" converter="#{operationConverter}" validator="operationValidator">
                    <f:selectItems value="#{utila.operations}" var="operation" itemValue="#{operation.id}" itemLabel="#{operation.operation}" />
                    <f:ajax event="blur" render="m_operation" />
                </h:selectOneMenu>
                <rich:message id="m_operation" for="operation" />
                
                <h:outputLabel for="name" value="Nome:" />
                <h:inputText id="name" value="#{productc.productb.product.name}">
                    <f:ajax event="blur" listener="#{pv.name}" render="m_name" />
                </h:inputText>
                <rich:message id="m_name" for="name" ajaxRendered="false" />
                
                <h:outputLabel for="quantity" value="Quantidade:" />
                <h:inputText id="quantity" value="#{productc.productb.product.quantity}" converterMessage="somente números" size="7" maxlength="7">
                    <f:convertNumber minIntegerDigits="1" maxIntegerDigits="7" />
                    <f:ajax event="blur" listener="#{pv.quantity}" render="m_quantity" />
                </h:inputText>
                <rich:message id="m_quantity" for="quantity" ajaxRendered="false" />
               
               <h:outputLabel for="measure" value="Unidade:" />
                <h:selectOneMenu id="measure" value="#{productc.productb.product.measure}" converter="#{measureConverter}" validator="measureValidator" >
                    <f:selectItems value="#{utila.measures}" var="measure" itemValue="#{measure.id}" itemLabel="measure.measure" />
                    <f:ajax event="blur" render="m_measure" />
                </h:selectOneMenu>
                <rich:message id="m_measure" for="measure" />
                
                <h:outputLabel for="state" value="Estado:" />
                <h:selectOneMenu id="state" value="#{productc.productb.product.location.state}" converter="#{stateConverter}" validator="stateValidator">
                    <f:selectItems value="#{utila.states}" var="state" itemValue="#{state.id}" itemLabel="state.state" />
                    <f:ajax event="blur" listener="#{pv.state}" render="m_state" />
                </h:selectOneMenu>
                <rich:message id="m_state" for="state" />
                
                <h:outputLabel for="city" value="Cidade:" />
                <h:inputText id="city" value="#{productc.productb.product.location.city.city}">
                    <f:ajax event="blur" listener="#{pv.city}" render="m_city" />
                </h:inputText>
                <rich:message id="m_city" for="city" ajaxRendered="false" />
                
                 <h:outputLabel for="locale" value="Local:" />
                <h:inputText id="locale" value="#{productc.productb.product.location.locale}">
                    <f:ajax event="blur" listener="#{pv.locale}" render="m_locale" />
                </h:inputText>
                <rich:message id="m_locale" for="locale" ajaxRendered="false" />

            </h:panelGrid>

            <h:panelGrid>
                <h:outputLabel for="description" value="Descrição do produto:" />
                <h:inputTextarea id="description" value="#{productc.productb.product.description}" cols="50" rows="10" />
                <h:outputText />
            </h:panelGrid>
            
                <h:commandButton value="Adicionar" action="#{productc.add}" />
        </h:form>
        <br/>
        <h:link value="Voltar" outcome="/user/home.xhtml"/>
        <ui:include src="/resources/jsf/component/composition/system/popup-product.xhtml" />
        
    </ui:define> 
        
    <ui:define name="right-content" />

</ui:composition>
</html>